/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.util.ArrayList;
import model.Chitietdaugia;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import util.HibernateUtil;

/**
 *
 * @author HoangLiem
 */
public class ChiTietDauGiaDAO {

    public static ArrayList<Chitietdaugia> getBidDetails(String maSanPham) {
        ArrayList<Chitietdaugia> list = null;
        try {
            SessionFactory ssFac = HibernateUtil.getSessionFactory();
            Session session = ssFac.getCurrentSession();
            session.beginTransaction();
            String hql = "from Chitietdaugia ctdg where ctdg.sanpham.maSanPham=:maSanPham";
            Query query = session.createQuery(hql);
            query.setString("maSanPham", maSanPham);
            list = (ArrayList<Chitietdaugia>) query.list();
        } catch (Exception ex) {
            ex.printStackTrace();
            list = null;
        }
        return list;
    }
}
